class AddStuffToSources < ActiveRecord::Migration
  def self.up
  	add_column :sources, :source_type_id, :integer
  	add_column :sources, :pull_interval, :integer
  	add_column :sources, :pulled_at, :datetime
  	add_column :sources, :keywords, :text
  	add_column :sources, :is_enabled, :boolean
  	add_column :sources, :languages, :string
  	add_column :sources, :username, :string
  	add_column :sources, :password, :string
  	add_column :sources, :reset_needed, :boolean
  	execute("update sources set keywords=query")
  	remove_column :sources, :query
  	remove_column :sources, :kind
  	remove_column :sources, :type
  	remove_column :sources, :scraped_at
  end

  def self.down
    add_column :sources, :kind, :string
    add_column :sources, :type, :string
    add_column :sources, :scraped_at, :datetime
    add_column :sources, :query, :text
    execute("update sources set query=keywords")
    remove_column :sources, :source_type_id
  	remove_column :sources, :pull_interval
  	remove_column :sources, :pulled_at
  	remove_column :sources, :keywords
  	remove_column :sources, :is_enabled
  	remove_column :sources, :languages
  	remove_column :sources, :username
  	remove_column :sources, :password
  	remove_column :sources, :reset_needed, :boolean
  end
end
